﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Upreader.Usenet.Nntp
{
    public sealed class StreamChainBuilderEntry
    {
        public StreamChainBuilderEntry(int priority, Func<Stream, Stream> factoryMethod)
        {
            if (factoryMethod == null)
                throw new ArgumentNullException("factoryMethod");

            Priority = priority;
            FactoryMethod = factoryMethod;
        }

        public int Priority { get; private set; }

        public Func<Stream, Stream> FactoryMethod { get; private set; }
    }

    sealed class StreamChainBuilderEntryComparer : Comparer<StreamChainBuilderEntry>
    {
        public override int Compare(StreamChainBuilderEntry x, StreamChainBuilderEntry y)
        {
            if (x == null)
                return -1;
            if (y == null)
                return 1;

            return x.Priority - y.Priority;
        }
    }
}
